1 /**************************************************************************\ 2 * 3 * Copyright (c) 2000, Microsoft Corp. All Rights Reserved. 4 * 5 * Module Name: 6 * 7 * GdiplusFontCollection.h 8 * 9 * Abstract: 10 * 11 * Font collections (Installed and Private) 12 * 13 \**************************************************************************/ 14 15 #ifndef _GDIPLUSFONTCOLL_H 16 #define _GDIPLUSFONTCOLL_H 17 18 inline 19 FontCollection::FontCollection() 20 { 21 nativeFontCollection = NULL; 22 } 23 24 inline 25 FontCollection::~FontCollection() 26 { 27 } 28 29 inline INT 30 FontCollection::GetFamilyCount() const 31 { 32 INT numFound = 0; 33 34 lastResult = DllExports::GdipGetFontCollectionFamilyCount( 35 nativeFontCollection, &numFound); 36 37 38 39 return numFound; 40 } 41 42 inline Status 43 FontCollection::GetFamilies( 44 IN INT numSought, 45 OUT FontFamily * gpfamilies, 46 OUT INT * numFound 47 ) const 48 { 49 if (numSought <= 0 || gpfamilies == NULL || numFound == NULL) 50 { 51 return SetStatus(InvalidParameter); 52 } 53 *numFound = 0; 54 GpFontFamily **nativeFamilyList = new GpFontFamily*[numSought]; 55 56 if (nativeFamilyList == NULL) 57 { 58 return SetStatus(OutOfMemory); 59 } 60 61 Status status = SetStatus(DllExports::GdipGetFontCollectionFamilyList( 62 nativeFontCollection, 63 numSought, 64 nativeFamilyList, 65 numFound 66 )); 67 if (status == Ok) 68 { 69 for (INT i = 0; i < *numFound; i++) 70 { 71 DllExports::GdipCloneFontFamily(nativeFamilyList[i], 72 &gpfamilies[i].nativeFamily); 73 } 74 } 75 76 delete [] nativeFamilyList; 77 78 return status; 79 } 80 81 inline Status FontCollection::GetLastStatus () const 82 { 83 return lastResult; 84 } 85 86 // protected method 87 inline Status 88 FontCollection::SetStatus(IN Status status) const 89 { 90 lastResult = status; 91 return lastResult; 92 } 93 94 inline 95 InstalledFontCollection::InstalledFontCollection() 96 { 97 nativeFontCollection = NULL; 98 lastResult = DllExports::GdipNewInstalledFontCollection(&nativeFontCollection); 99 } 100 101 inline 102 InstalledFontCollection::~InstalledFontCollection() 103 { 104 } 105 106 #ifndef DCR_USE_NEW_235072 107 inline Status 108 InstalledFontCollection::InstallFontFile(IN const WCHAR* filename) 109 { 110 return SetStatus(DllExports::GdipInstallFontFile(nativeFontCollection, filename)); 111 } 112 113 inline Status 114 InstalledFontCollection::UninstallFontFile(IN const WCHAR* filename) 115 { 116 return SetStatus(DllExports::GdipUninstallFontFile(nativeFontCollection, filename)); 117 } 118 #endif 119 120 inline 121 PrivateFontCollection::PrivateFontCollection() 122 { 123 nativeFontCollection = NULL; 124 lastResult = DllExports::GdipNewPrivateFontCollection(&nativeFontCollection); 125 } 126 127 inline 128 PrivateFontCollection::~PrivateFontCollection() 129 { 130 DllExports::GdipDeletePrivateFontCollection(&nativeFontCollection); 131 } 132 133 inline Status 134 PrivateFontCollection::AddFontFile(IN const WCHAR* filename) 135 { 136 return SetStatus(DllExports::GdipPrivateAddFontFile(nativeFontCollection, filename)); 137 } 138 139 inline Status 140 PrivateFontCollection::AddMemoryFont(IN const void* memory, 141 IN INT length) 142 { 143 return SetStatus(DllExports::GdipPrivateAddMemoryFont( 144 nativeFontCollection, 145 memory, 146 length)); 147 } 148 149 #endif // _GDIPLUSFONTCOLL_H 150